/*
 * mine.cc
 *
 *  Created on: Oct 26, 2009
 *      Author: price
 */

// dynamic_cast
#include <iostream>
#include <vector>
#include <exception>
#include "includes/intnumberobject.h"
#include  "includes/realnumberobject.h"
#include "includes/utf8stringobject.h"
#include "includes/unicodestringobject.h"
#include "includes/arrayobject.h"
#include "includes/smartpointers/yasper.h"
using namespace std;
using namespace templatipus;

void TestConstructor() {
	int8 val1 = 'A';
	uint8 val2 = 2;
	int16 val3 = 3;
	uint16 val4 = 4;
	int32 val5 = 5;
	uint32 val6 = 6;
	int64 val7 = 7;
	uint64 val8 = 8;
	float32 val9 = 9;
	float64 val10 = 10;
	std::string str1 = "string1";
	utf8Ptr str2 = "string2";
	unicodePtr str3 =L"string3" ;
	std::wstring str4= L"string4";

	TUtf8StringObject string_1(val1);
	TUtf8StringObject string_2((int32)val2);
	TUtf8StringObject string_3(val3);
	TUtf8StringObject string_4((int32)val4);
	TUtf8StringObject string_5(val5);
	TUtf8StringObject string_6((int32)val6);
	TUtf8StringObject string_7(val7);
	TUtf8StringObject string_8((int64)val8);
	TUtf8StringObject string_9(val9);
	TUtf8StringObject string_10(val10);
	TUtf8StringObject string_11(str1);
	TUtf8StringObject string_12(str2);
	TUtf8StringObject string_13(str3);
	TUtf8StringObject string_14(str4);
	TUtf8StringObject string_15(string_1);

	cout<<string_1.toString().c_str()<<endl;
	cout<<string_2.toString().c_str()<<endl;
	cout<<string_3.toString().c_str()<<endl;
	cout<<string_4.toString().c_str()<<endl;
	cout<<string_5.toString().c_str()<<endl;
	cout<<string_6.toString().c_str()<<endl;
	cout<<string_7.toString().c_str()<<endl;
	cout<<string_8.toString().c_str()<<endl;
	cout<<string_9.toString().c_str()<<endl;
	cout<<string_10.toString().c_str()<<endl;
	cout<<string_11.toString().c_str()<<endl;
	cout<<string_12.toString().c_str()<<endl;
	cout<<string_13.toString().c_str()<<endl;
	cout<<string_14.toString().c_str()<<endl;
	cout<<string_15.toString().c_str()<<endl;
}

void TestConversion() {
	TUtf8StringObject s1("10.45");

	cout << (int) s1.toInt8() << endl;
	cout << (int) s1.toUint8() << endl;

	cout << s1.toInt16() << endl;
	cout << s1.toUint16() << endl;

	cout << s1.toInt32() << endl;
	cout << s1.toUint32() << endl;

	cout << s1.toInt64() << endl;
	cout << s1.toUint64() << endl;

	cout << s1.toFloat32() << endl;
	cout << s1.toFloat64() << endl;
}

void TestOperators() {
	TUtf8StringObject string_1 = "silviu";
	TUtf8StringObject string_2 = " caragea";

	TUtf8StringObject string_3 = string_1 + string_2;
	cout << (std::string) string_3 << endl;

	//string_1 += string_2;

	//cout << (utf8Ptr) string_1 << endl;

}

void TestEqualOperators() {
	TUtf8StringObject obj1("2");
	TUtf8StringObject obj2("2");

	if (obj1 > obj2) {
		cout << ">>>>" << endl;
	} else if (obj1 < obj2) {
		cout << "<<<<" << endl;
	} else if (obj1 == obj2) {
		cout << "======" << endl;
	}
}

int main() {
	//TestConstructor();
	//TestConversion();
	TestOperators();
	//TestEqualOperators();
	TUtf8StringObject obj2("23435");
	utf8c sss = obj2[(int32) 1];

	printf("%d\n", sss);

	//	TUtf8StringObject obj("1");

	//	tbool var = (tbool)obj;
	std::vector<yasper::ptr<TRealNumberObject> > ls;
	yasper::ptr<TRealNumberObject> ptr = new TRealNumberObject(100L);
	yasper::ptr<TRealNumberObject> ptr1 = new TRealNumberObject(101L);
	uint32 i = (uint32) *ptr;
	ls.push_back(ptr);
	printf("Size of vector %i\n", ls.size());
	ls[0] = ptr1;
	printf("Size of vector %i\n", ls.size());

	TRealNumberObject objReal = "12.1";
	TRealNumberObject objReal1 = "13.1";
	TArrayObject arr;
	//arr.add(objReal);
	//arr.add(objReal1);
	cout<<(std::string)arr;


	const TemplateObject & arrIObj = arr[(uint64) 0];
	i = arrIObj;
	printf("%i\n", i);

	double d = objReal;
	TIntNumberObject obj = 100L;
	TIntNumberObject obj1 = 100L;
	TIntNumberObject objRes = (int32) (obj && obj1);

	i = objRes;
	printf("%i\n", i);

	return 0;
}

